package mi.payment.transaction.authorize;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import mi.payment.R;
import mi.payment.ui.base.InputMoneyActivity;

/**
 * 预授权模块 -- 输入金额界面
 */
public class PreAuthorizeInputMoneyActivity extends InputMoneyActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBtnOk.setText(R.string.gathering);
        mTvTitle.setText(R.string.pre_auth);
    }

    @Override
    public void onClick(View v) {
        if (v == mBtnOk) {
            clickOK();
        }
    }

    public void clickOK() {
        mInputAmount = amountInputView.getAmountText().toString();
        boolean equals = TextUtils.equals("0.00", mInputAmount);
        if (equals) {
            showToast(R.string.money_input_hint);
        } else {
            boolean isForceInputPwd = getIntent().getBooleanExtra("extra_force_input_pwd", false);
            PreAuthorizeSwingCardActivity.startAction(this, mInputAmount, isForceInputPwd);
            finish();
        }
    }

    /**
     * 是否需要强制输密
     */
    public static void startAction(Context context, boolean forceInputPwd) {
        Intent intent = new Intent(context, PreAuthorizeInputMoneyActivity.class);
        intent.putExtra("extra_force_input_pwd", forceInputPwd);
        context.startActivity(intent);
    }


}
